<template>
  <view
    :class="{actionBtn: true, actionBtn0: position == 0, actionBtn1: position == 1, actionBtn2: position == 2, actionBtn3: position == 3 }"
    v-if="$orderModuleShowActionBtn(position)"
    @click.stop="clickHandler"
  >
    归还
  </view>
</template>

<script>
// 归还按钮
import { checkPosition, getOrderId } from "../utils/checkShowBtn.js"
import { sendbackPageProductGlobalKey } from "../../../../utils/constant"

export default {
  name: "guihuan",
  
  props: {
    order: {
      type: Object,
      default: {},
    }, // 订单对象
    isUsedInList: {
      type: Boolean,
      default: true,
    }, // 是否使用在订单列表页面
    product: {
      type: Object,
      default: null,
    }
  },

  data() {
    return {}
  },

  computed: {
    position: function() {
      return checkPosition.guihuan(this.order, this.isUsedInList)
    }
  },
  
  methods: {
    /**
     * 点击按钮时的回调方法
     */
    clickHandler() {
      this.$setGlobalData(sendbackPageProductGlobalKey, this.product || this.order) // 将商品数据保存到全局，供归还页面反显商品信息数据
      this.$onTo(`/pages/sendback/sendback?orderId=${getOrderId(this.order)}`)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
